<h1 id="nmcli">nmcli</h1>
<p>地址配置工具</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>nmcli命令</strong> 是 NetworkManager client 网络管理客户端。</p>
<h3 id="语法">语法</h3>
<div class="sourceCode" id="cb1"><pre><code class="language-bash"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="ex">nmcli</span> [OPTIONS] OBJECT { COMMAND <span class="kw">|</span> <span class="bu">help</span> }</a></code></pre></div>
<h3 id="选项">选项</h3>
<div class="sourceCode" id="cb2"><pre><code class="language-bash"><a class="sourceLine" id="cb2-1" data-line-number="1"><span class="ex">OPTIONS</span></a>
<a class="sourceLine" id="cb2-2" data-line-number="2">  <span class="ex">-t</span>[erse]                                   terse output 简洁的输出</a>
<a class="sourceLine" id="cb2-3" data-line-number="3">  <span class="ex">-p</span>[retty]                                  pretty output 漂亮的输出</a>
<a class="sourceLine" id="cb2-4" data-line-number="4">  <span class="ex">-m</span>[ode] tabular<span class="kw">|</span><span class="ex">multiline</span>                  output mode  输出模式</a>
<a class="sourceLine" id="cb2-5" data-line-number="5">  <span class="ex">-f</span>[ields] <span class="op">&lt;</span>field1,field2,...<span class="op">&gt;</span><span class="kw">|</span><span class="ex">all</span><span class="kw">|</span><span class="ex">common</span>   specify fields to output 指定要输出的字段</a>
<a class="sourceLine" id="cb2-6" data-line-number="6">  <span class="ex">-e</span>[scape] yes<span class="kw">|</span><span class="ex">no</span>                           escape columns separators in values 在值中转义列分隔符</a>
<a class="sourceLine" id="cb2-7" data-line-number="7">  <span class="ex">-n</span>[ocheck]                                 不要检查nmcli和NetworkManager版本</a>
<a class="sourceLine" id="cb2-8" data-line-number="8">  <span class="ex">-a</span>[sk]                                     要求缺少参数</a>
<a class="sourceLine" id="cb2-9" data-line-number="9">  <span class="ex">-w</span>[ait] <span class="op">&lt;</span>seconds<span class="op">&gt;</span>                          设置超时等待整理操作</a>
<a class="sourceLine" id="cb2-10" data-line-number="10">  <span class="ex">-v</span>[ersion]                                 显示程序版本</a>
<a class="sourceLine" id="cb2-11" data-line-number="11">  <span class="ex">-h</span>[elp]                                    打印此帮助</a>
<a class="sourceLine" id="cb2-12" data-line-number="12"></a>
<a class="sourceLine" id="cb2-13" data-line-number="13"><span class="ex">OBJECT</span></a>
<a class="sourceLine" id="cb2-14" data-line-number="14">  <span class="ex">g</span>[eneral]       NetworkManager的一般状态和操作</a>
<a class="sourceLine" id="cb2-15" data-line-number="15">  <span class="ex">n</span>[etworking]    整体组网控制</a>
<a class="sourceLine" id="cb2-16" data-line-number="16">  <span class="ex">r</span>[adio]         NetworkManager切换开关</a>
<a class="sourceLine" id="cb2-17" data-line-number="17">  <span class="ex">c</span>[onnection]    NetworkManager的连接</a>
<a class="sourceLine" id="cb2-18" data-line-number="18">  <span class="ex">d</span>[evice]        由NetworkManager管理的设备</a>
<a class="sourceLine" id="cb2-19" data-line-number="19">  <span class="ex">a</span>[gent]         NetworkManager秘密代理或polkit代理</a></code></pre></div>
<h3 id="实例">实例</h3>
<div class="sourceCode" id="cb3"><pre><code class="language-bash"><a class="sourceLine" id="cb3-1" data-line-number="1"><span class="ex">nmcli</span> connection show           # 查看当前连接状态</a>
<a class="sourceLine" id="cb3-2" data-line-number="2"><span class="ex">nmcli</span> connection reload         # 重启服务</a>
<a class="sourceLine" id="cb3-3" data-line-number="3"><span class="ex">nmcli</span> connection show -active   # 显示活动的连接</a>
<a class="sourceLine" id="cb3-4" data-line-number="4"><span class="ex">nmcli</span> connection show <span class="st">&quot;lan eth0&quot;</span># 显示指定一个网络连接配置</a>
<a class="sourceLine" id="cb3-5" data-line-number="5"><span class="ex">nmcli</span> device status             # 显示设备状态</a>
<a class="sourceLine" id="cb3-6" data-line-number="6"><span class="ex">nmcli</span> device show eno16777736   # 显示指定接口属性</a>
<a class="sourceLine" id="cb3-7" data-line-number="7"><span class="ex">nmcli</span> device show               # 显示全部接口属性</a>
<a class="sourceLine" id="cb3-8" data-line-number="8"><span class="ex">nmcli</span> con up static             # 启用static连接配置</a>
<a class="sourceLine" id="cb3-9" data-line-number="9"><span class="ex">nmcli</span> con up default            # 启用default连接配置 </a>
<a class="sourceLine" id="cb3-10" data-line-number="10"><span class="ex">nmcli</span> con add help              # 查看帮助</a></code></pre></div>
<!-- Linux命令行搜索引擎：https://jaywcjlove.github.io/linux-command/ -->
